<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    template="/WEB-INF/templates/common.xhtml">

           <ui:define name="pageTitle">Detalhe Pessoa</ui:define>

           <ui:define name="pageHeader">Pessoa</ui:define>

           <ui:define name="body">
                        
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table" />
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="Nome*:"/>
                    <h:inputText label="Nome" value="#{person.name}" title="Nome" maxlength="50" required="true" requiredMessage="Nome: Campo Obrigatório"/>                    
                    <h:outputText value="Data de Nascimento*:"/>
                    <h:inputText id="datanascimento" label="Data Nascimento" value="#{person.birthDate}" title="Data" required="true" maxlength="10" 
                                     requiredMessage="Data Nascimento: Campo Obrigatório"
                                     converterMessage="Data Nascimento deve ter o formato dd/mm/aaaa" 
                                     validator="#{personDetailController.validateBirthDate}">
                                                        <f:convertDateTime type="date" dateStyle="" pattern="dd/MM/yyyy" />  
                                        </h:inputText>
               </h:panelGrid>
               <p><b>Experiências</b></p>
               <ui:repeat value="#{person.personExperiences}" var="personExperience" varStatus="loop">
                        Empresa*: <h:inputText value="#{personExperience.enterpriseName}" maxlength="50" required="true" requiredMessage="Empresa: Campo Obrigatório"/>&nbsp;
                        <h:commandButton action="#{personDetailController.deleteExperience(personExperience)}" value="Excluir Experiencia" image="/images/remove.png" /><br/>
               </ui:repeat>
               <br/><br/><br/>

               <h:commandButton action="#{personDetailController.newExperience}" value="Nova Experiencia" /><br/><br/>
               <h:commandButton action="#{personDetailController.save(person)}" value="Salvar" /><br/>
               <br/><br/><br/>
               <h:commandButton value="Voltar" action="/person/list" />
                </h:form>
                    
                </ui:define>
        </ui:composition>